- content_for :head do
  = javascript_include_tag "AC_ActiveX"
  = javascript_include_tag "AC_RunActiveContent"
%h1.page_title Edit Video Details
%table.edit_video
  %tr
    %td.edit{:colspan => 2}
      %div.flash_video_container
        %div.flash_video
          %script{:type => "text/javascript"}
            = "AC_AX_RunContent( 'classid','clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B','width','853','height','496','codebase','http://www.apple.com/qtactivex/qtplugin.cab','src','" + @video.public_filename.to_s + "','autoplay','false','controller','true','pluginspage','http://www.apple.com/quicktime/download/' );"
          %noscript
            %object{:classid => "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B", :width => "853", :height => "514", :codecase => "http://www.apple.com/qtactivex/qtplugin.cab"}
              %param{:name => "SRC", :value => @video.public_filename}
              %param{:name => "AUTOPLAY", :value => "true"}
              %param{:name => "CONTROLLER", :value => "true"}
              %embed{:src => @video.public_filename, :width => "853", :height => "514", :autoplay => "true", :controller => "true", :pluginspace => "http://www.apple.com/quicktime/download/"}
  - form_for @video, :method => :update do |form|
    %tr
      %td.field_title Title:
      %td.field= form.text_field :title
      %td.error= error_message_on :video, :title
    %tr
      %td.field_title Caption: 
      %td.field= form.text_field :caption
      %td.error= error_message_on :video, :caption
    %tr
      %td.field_title Description:
      %td.field= form.text_area :description
      %td.error= error_message_on :video, :description
    %tr
      %td.field_title Galleries:
      %td.field
        - if @galleries.empty?
          No galleries have been created yet.
          %a{:href => new_gallery_url, :title => "Create a new Gallery"}Create one
        - else
          %select{:id => "video[gallery_ids][]", :name => "video[gallery_ids][]", :multiple => true, :size => 8, :width => 10}
            - @galleries.each do |gallery|
              %option{:value => gallery.id, :selected => ("selected" if @video.galleries.include?(gallery))}= gallery.name
      %td.error= error_message_on :video, :gallery_ids
    %tr
      %td.field_title Thumbnail:
      %td.field
        %div.video_thumbnails
          - @thumbnails.each do |photo|
            %table.video_photo
              %tr
                %td.photo
                  %a{:href => photo_url(photo), :title => (photo.caption ? photo.caption : photo.filename), :alt => (photo.caption ? photo.caption : photo.filename)}
                    %img.photo_thumb{:src => photo.public_filename(:thumb), :title => (photo.caption ? photo.caption : photo.filename), :alt => (photo.caption ? photo.caption : photo.filename)}
              %tr
                %td.check_box
                  = radio_button_tag("video[photo_id]", photo.id, photo == @video.photo)
    %tr
      %td.field_title Options:
      %td
        %table.video_options
          %tr
            %td.video_options_field= check_box_tag("video[random]", 1, @video.random?)
            %td.video_options_field_title One of the videos that cycles on the homepage
            %td.error= error_message_on :video, :random
          %tr
            %td.video_options_field= check_box_tag("video[non_purchasable]",1, @video.non_purchasable?)
            %td.video_options_field_title Make unavailable for purchase
            %td.error= error_message_on :video, :non_purchasable
          %tr
            %td.video_options_field=check_box_tag("video[is_private]", 1, @video.is_private?)
            %td.video_options_field_title Mark this video as private
            %td.error= error_message_on :video, :is_private
    %tr
      %td
      %td.submit= submit_tag 'update'
  - form_for @video, videos_url, :html => {:method => :delete} do |form|
    %tr
      %td
      %td.submit= submit_tag 'Delete this video'
%h2 Comments
- if @video.comments.empty?
  %p No one has said anything about this photo yet.
-else 
  %div.video_comments
    - @video.comments.each do |comment|
      %div.comment_container
        %div.creation_information
          %div.user_login
            %a{:href => user_url(comment.user)}= comment.user.login
          %div.comment_time
            = comment.created_at.strftime("%m/%d/%y at %I:%M %p")
          - if logged_in? && current_user.is_admin?
            %div.delete_comment
              - form_for comment, :html => {:method => :delete} do |form|
                = submit_tag "delete"
        %div.user_comment
          = comment.text
      %div.clear_fix